﻿/*
 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

#ifndef BURNDLGSLE_H
#define BURNDLGSLE_H

#include <windows.h>
#include "BurnDlg.h"
#include "ui_BurnDlgSle.h"
#include "BurnCtrl/BurnCtrlSle.h"

namespace BurnDlg {
using namespace BurnCtrlSleClass;
class BurnDlgSle : public BurnDlg {
    Q_OBJECT
public:
    explicit BurnDlgSle(QWidget *parent = nullptr);
    ~BurnDlgSle() override;

signals:
    void SignalSendMsg(long int msgId, WPARAM wParam, LPARAM lParam);
protected slots:
    void SlotInsertPlainText(const QString &editStr) override;
    void SlotCbnSetfocusComboCom();
    void SlotBtnClickedConnect();
    void SlotBtnClickedStart();
    void SlotBtnClickedSelectfile();
    void SlotSetAddress(const QVector<SleDeviceInfo>& info);
    void SlotBtnClickedOpen();
    void SlotOpenDeviceFail() const;
    void SlotConnectResult(bool result) const;
    void SlotSetProgress(double progress) const;
    void SlotCreateNewFwpkgFile();
    void SlotSaveSpiltFwpkgFile();
protected:
    void InitConnect() const;
    void HidEnumerate();
    HANDLE OpenDevice(const CHAR *path, BOOL openRw) const;
    void AnalyseBinFile(QString filePath);
    void InitTableView() const;
    void UpdateList() override;
    void UpdateList(BIN_INFO_ARRAY &info) const;
    void HidEnumerateInterface(CHAR* deviceInterfaceList, DWORD len);
    void InitMenus();
    void contextMenuEvent(QContextMenuEvent *event) override;
private:
    Ui::BurnDlgSle *ui;
    QMap<QString, HidDeviceInfo> hidShowInfoMap;
    QMap<QString, HidDeviceInfo> deviceInterfaceMap;
    QMap<QString, QString> deviceShowInfoMap;
    BurnCtrlSle *burnCtrlSle;
    MyThreadClass::MyThread *sleThread;
    QMap<int, BIN_INFO> burnInfo;
    QAction *actAbout;
    AboutWindow *aboutWin;
    QAction *actChangeChip;
    ChangeChip *changeChip;
    QVector<SleDeviceInfo> infoDeviceInfo;
    QMenu *tableViewMenu;
};
}
#endif // BURNDLGSLE_H
